package com.lfk.justweengine.utils.music;

import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import org.junit.Assert;
import org.junit.Test;

public class MusicPlayerOhosTest {

    @Test
    public void testPlay() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.play();
        flg = true;
        Assert.assertTrue(flg);
    }

    @Test
    public void testStop() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.stop();
        flg = true;
        Assert.assertTrue(flg);
    }

    @Test
    public void testPause() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.pause();
        flg = true;
        Assert.assertTrue(flg);
    }

    @Test
    public void testSetLooping() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.setLooping(true);
        flg = true;
        Assert.assertTrue(flg);
    }

    @Test
    public void testSetVolume() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.setVolume(5.0f);
        flg = true;
        Assert.assertTrue(flg);
    }

    @Test
    public void testGetVolume() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.setVolume(6);
        Assert.assertEquals("6.0",String.valueOf(musicPlayer.getVolume()));

    }

    @Test
    public void testDispose() {
        boolean flg = false;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        MusicPlayer musicPlayer = new MusicPlayer(context,"resources/rawfile/media/test.mp4");
        musicPlayer.dispose();
        flg = true;
        Assert.assertTrue(flg);
    }
}